<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../js/vue.js"></script>
    <script src="../js/dayjs.min.js"></script>
</head>

<body>
    <div id="contain">
        <h2>显示时间</h2>
        <h3>{{time}}</h3>
        <!-- 计算属性后实现 -->
        <h3>{{futime}}</h3>
        <!-- 通过方法实现 -->
        <h3>{{nowtime()}}</h3>
        <!-- 过滤器实现 -->
        <h3>现在是:{{time | timeformater}}</h3>
    </div>
    <script>
        const vm = new Vue({
            el: '#contain',
            data: {
                time: Date.now()
            },
            computed: {
                futime() {
                    return dayjs(this.time).format('YYYY-MM-DD HH:mm:ss')
                }
            }, methods: {
                nowtime() {
                    return dayjs(this.time).format('YYYY-MM-DD HH:mm:ss')
                }
            }, filters: {
                timeformater() {
                    return dayjs(this.time).format('YYYY-MM-DD HH:mm:ss')
                }
            }
        });
    </script>
</body>

</html>